package com.fg.pro.trade.controller;




import com.fg.pro.model.reponse.ResponseResult;
import com.fg.pro.trade.service.TradeCustomerService;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


/**
 * 客户(TradeCustomer)表控制层
 *
 * @author makejava
 * @since 2025-08-21 10:05:02
 */
@RestController
@RequestMapping("tradeCustomer")
@Tag(name = "tradeCustomer",description = "客户")
public class TradeCustomerController {
    /**
     * 服务对象
     */
    @Resource
    private TradeCustomerService tradeCustomerService;

    @Operation(summary = "获取单位分页",description = "")
    @GetMapping("/getPage")
    public ResponseResult getPage(@RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                  @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                  @RequestParam(required = false)String customerName){
        PageInfo pageInfo = tradeCustomerService.getPage(pageNum,pageSize,customerName);
        return ResponseResult.okResult(pageInfo);
    }

    @Operation(summary = "刷新客户",description = "参数时间，可以不传参，默认刷新时间当前")
    @PostMapping("/refresh")
    public ResponseResult refresh(@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) throws InterruptedException {
        boolean flag = tradeCustomerService.refresh(date);
        return ResponseResult.okResult(flag?"刷新成功":"正在刷新中。。。");
    }
}

